use askama::Template;


mod filters {
    use askama::Result;   
     use std::fmt::Arguments;
    pub fn pascalcase(s: &str, _: &dyn askama::Values) -> Result<String> {
        Ok(s.to_string())
} 
 pub fn camelcase(s: &str, _: &dyn askama::Values) -> Result<String> {
        Ok(s.to_string())
    }

}

#[derive(Template)]
#[template(path = "model.txt")] // 指向模板文件
struct CppModelTemplate {
    model_name: String,
    class_name: String,
    fields: Vec<Field>,
}

struct Field {
    name: String,
    r#type: String,
    comment: String,
}



pub fn generate_cpp_model() -> askama::Result<String> {
    let template = CppModelTemplate {
        model_name: "user".to_string(),
        class_name: "user_model".to_string(),
        fields: vec![
            Field {
                name: "user_id".to_string(),
                r#type: "int32_t".to_string(),
                comment: "用户唯一ID".to_string(),
            },
            Field {
                name: "user_name".to_string(),
                r#type: "std::string".to_string(),
                comment: "用户登录名".to_string(),
            },
        ],
    };
    
    template.render()
}